home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / objectex / ex35.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  657 b   |  32 lines

  1. Program ex35;
  2.  
  3. { Program to demonstrate the TSortedCollection.Insert method }
  4.  
  5. Uses Objects,MyObject,MySortC; 
  6.  { For TMyObject,TMySortedCollection definition and registration }
  7.  
  8. Var C : PSortedCollection;
  9.     M : PMyObject;
  10.     I : Longint;
  11.  
  12. Procedure PrintField (Dummy: Pointer;P : PMyObject);
  13.  
  14. begin
  15.   Writeln ('Field : ',P^.GetField);
  16. end;
  17.  
  18.  
  19. begin
  20.   Randomize;
  21.   C:=New(PMySortedCollection,Init(120,10));
  22.   Writeln ('Inserting 100 records at random places.');
  23.   For I:=1 to 100 do
  24.     begin
  25.     M:=New(PMyObject,Init);
  26.     M^.SetField(Random(100));
  27.     C^.Insert(M)
  28.     end;
  29.   Writeln ('Values : ');
  30.   C^.Foreach(@PrintField);   
  31.   Dispose(C,Done);
  32. end.